package me.zhengjie.pm.projecttask.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import me.zhengjie.pm.projectstageprogress.domain.ProjectStageProgress;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.Immutable;

/**
* @author yuxj
* @date 2020-04-14
* 这个实体为视图，不涉及插入，更新等操作，只能查询。
*/
@Entity
@Data
@Immutable
@Table(name="project_all_task_view")
public class ProjectAllTaskView implements Serializable {

    /** ID */
    @Id
    @Column(name = "id")
    private String id;

    /** 项目 */
    @Column(name = "project_id")
    private Integer projectId;

    /** 项目阶段 */
    @Column(name = "stage_id")
    private Integer stageId;

    /** 计划完成时间 */
    @Column(name = "plan_finish_time")
    private Timestamp planFinishTime;

    /** 任务类型 */
    @Column(name = "type")
    private String type;

    /** 项目名称 */
    @Column(name = "project_name")
    private String projectName;

    /** 阶段名称 */
    @Column(name = "stage_name")
    private String stageName;

    /** 任务简要描述 */
    @Column(name = "simple_describe")
//    @ColumnTransformer(
//            read = "CAST(AES_DECRYPT(UNHEX(simple_describe), 'rjb') as char(128))",
//            write = "HEX(AES_ENCRYPT(?, 'rjb'))"
//    )
    private String simpleDescribe;

    /** 安排任务人数 */
    @Column(name = "worker_no")
    private Integer workerNo;

    /** 当前完成状态 */
    @Column(name = "work_state")
    private String workState;

    public void copy(ProjectAllTaskView source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}